#include <QCoreApplication>
#include<iostream>
#include<QString>

using namespace std;

int removeDuplicates(QList<int>nums) //函数定义
{
    if(nums.length() == 0) //数组为空，则返回0
        return 0;
    int i =0; //record length
    for(int j=1; j<nums.length();j++)
    {
       if (nums[j] != nums[i])
       {
          i++;
          nums[i] = nums[j];
       }

    }
    cout<<"new groups include:";  //输出原数组的前（i+1）个值，就是不重复的
    for (int k=0;k<(i+1);k++)
    {
       cout<<nums[k];
    }
    return i + 1;
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QList<int>nums={0,1,1,1,2,2,3,4,4,5,6};  //有序数组硬编码，且打印,
    cout<<"groups include:";
    for(int k=0;k<nums.size();k++)
    {
        cout<<nums[k];
    }
    cout<<endl;
    //输出数组新长度
    cout<<endl<<"the length of new group is:"<<removeDuplicates(nums);
    return a.exec();
}
